public class test3 {
    //力扣 LCR 099.最小路径和
    public int minPathSum(int[][] grid) {
        //创建dp数组
        //初始化
        //填表
        //返回值

        int m = grid.length,n = grid[0].length;
        int[][] dp = new int[m+1][n+1];
        //这里的初始化一定要小心注意
        for(int j = 2;j<n+1;j++){
            dp[0][j] = 201;
        }
        for(int i = 2;i<m+1;i++){
            dp[i][0] = 201;
        }

        for(int i = 1;i<m+1;i++){
            for(int j = 1;j<n+1;j++){
                dp[i][j] = Math.min(dp[i][j-1],dp[i-1][j])+grid[i-1][j-1];
            }
        }

        return dp[m][n];
    }
}
